﻿using System;

namespace NET.Library.Manipulation
{
    /// <summary>
    /// Decimals Manipulation Object.
    /// </summary>
    public class Decimals
    {
        /// '-----------------------------------------------------------------------------------------
        /// 'returns decimal values
        /// '-----------------------------------------------------------------------------------------
        public static int decGetVal(object Value)
        {
            return Value == DBNull.Value ? int.MinValue : (int)Value;
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Checks if a string is a decimal value.
        /// </summary>
        /// <param name="stringToCheck"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static bool IsDecimal(string stringToCheck)
        {
            decimal result;
            bool isDecimal = true;
            if (stringToCheck == null)
            {
                stringToCheck = "";
            }
            try
            {
                result = decimal.Parse(stringToCheck);
            }
            catch
            {
                isDecimal = false;
            }
            return isDecimal;
        }
    }
}
